// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "PaperCharacter.h"
#include "Character2D.generated.h"

UENUM(BlueprintType)
enum EMoveState
{
	None,
	Up,
	Down,
	Left,
	Right
};

/**
 * 
 */
UCLASS()
class XCZ3_API ACharacter2D : public APaperCharacter
{
	GENERATED_BODY()

	UPROPERTY(VisibleAnywhere)
	class USpringArmComponent* SpringArmComponent;

	UPROPERTY(VisibleAnywhere)
	class UCameraComponent* CameraComponent;

	UPROPERTY(EditAnywhere)
	class UInputMappingContext* InputMappingContext;

	UPROPERTY(EditAnywhere)
	class UInputAction* IA_Movement;

	UPROPERTY(EditAnywhere)
	TMap<FString, class UPaperFlipbook*> CharacterAnimations;

	UPROPERTY(EditAnywhere)
	TEnumAsByte<EMoveState> MoveState;

	UPROPERTY(EditAnywhere)
	TSubclassOf<class ABullet> BulletActorToSpawn;

	FTimerHandle AutoFireTimerHandle;

	// 是否死亡
	bool bDead = false;
	bool bMoving = false;

	void StartMovement(const struct FInputActionValue& Value);
	void Movement(const struct FInputActionValue& Value);
	void CompletedMovement(const struct FInputActionValue& Value);
	EMoveState ComputeMovementDirection(const FVector& Value);
	void UpdateAnimation();
	UPaperFlipbook* GetAnimation();
	UPaperFlipbook* GetProperAnim(FString AnimName);
	void AutomaticFiring();
public:
	ACharacter2D();
	virtual void BeginPlay() override;

	virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
};
